#!/usr/bin/env python3

from pymysql import connect
import os
try:  # 这段try用于检查是否有数据库，没有则表示新机新安装
    conn = connect(host="localhost", user="root", passwd="1Qazxsw2", db="sl", port=3306)
    # conn.close()    #这里不能加close()，那是不是连上就不关了呢

except:
    conn = connect(host="localhost", user="root", passwd="1Qazxsw2", port=3306)
    curr = conn.cursor()
    comm = 'create database sl charset utf8;'
    curr.execute(comm)
    curr.close()  # 一定要关光标

cmd = 'python3 manage.py makemigrations'
os.system(cmd)
cmd = 'python3  manage.py migrate'
os.system(cmd)
cmd = 'python3 manage.py createsuperuser'
os.system(cmd)
cmd = 'python3 manage.py'
os.system(cmd)
